using System;
using System.Collections;
// 定义命令接口
public interface ICommand
{
    void Execute();
}

// 定义接收者类
public class Receiver
{
    public void Action()
    {
        Console.WriteLine("Receiver: Executing the action.");
    }
}

// 定义具体命令类
public class ConcreteCommand : ICommand
{
    private Receiver _receiver;

    public ConcreteCommand(Receiver receiver)
    {
        _receiver = receiver;
    }

    public void Execute()
    {
        _receiver.Action();
    }
}

// 定义调用者类
public class Invoker
{
    private ICommand _command;

    public void SetCommand(ICommand command)
    {
        _command = command;
    }

    public void Invoke()
    {
        _command.Execute();
    }
}

// 客户端代码
public class Client
{
    public static void Main()
    {
        Receiver receiver = new Receiver();
        ICommand command = new ConcreteCommand(receiver);
        Invoker invoker = new Invoker();

        invoker.SetCommand(command);
        invoker.Invoke();
    }
}

//输出结果：Receiver: Executing the action.